<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<link href="#springUrl('/static/css/bootstrap.min.css')" rel="stylesheet">
	<link href="#springUrl('/static/css/style.css')" rel="stylesheet">
    <link href="#springUrl('/static/css/jquery-ui.css')" rel="stylesheet">
</head>
<body class="white-bg">
<div class="ibox-content" style="width: 430px;">
   <form id="myForm" class="form-horizontal" autocomplete="off" data-validator-option="{theme:'default'}">
   	   <input type="hidden" name="id" value="$!{item.id}">
       <div class="form-group"><label class="col-sm-2 control-label">名称</label>
      		<div class="col-sm-10">
			<input type="text" class="form-control" name="itemName" value="$!{item.itemName}"  >
      		</div>
       </div>
        <div class="form-group"><label class="col-sm-2 control-label">图标</label>
            <div class="col-sm-10"><!--商品图标-->
            <input type="file" class="form-control" name="itemIconAddr" value="$!{item.itemIconAddr}"  >
            </div>
        </div>
       <div class="form-group"><label class="col-sm-2 control-label">商品图片</label>
           <div class="col-sm-10"><!--商品图片-->
               <input type="file" class="form-control" name="infoImageAddrs" value="$!{item.infoImageAddrs}"  >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">商品详情图片</label>
           <div class="col-sm-10"><!--商品详情图片-->
               <input type="file" class="form-control" name="infoBigImageAddr" value="$!{item.infoBigImageAddr}" >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">成分</label>
           <div class="col-sm-10"><!--商品成分-->
               <input type="text" class="form-control" name="itemCompose" value="$!{item.itemCompose}"  >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">产品效果</label>
           <div class="col-sm-10"><!--商品详情图片-->
               <input type="text" class="form-control" name="itemEffect" value="$!{item.itemEffect}"  >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">制造商</label>
           <div class="col-sm-10">
               <!--使用下拉列表-->
               <input type="text" class="form-control" name="manufactorId" value="$!{item.manufactorId}"  >
           </div>
       </div>
        <div class="form-group"><label class="col-sm-2 control-label">价格</label>
            <div class="col-sm-10">
            <input type="text" class="form-control" name="price" value="$!{item.price}"  >
            </div>
        </div>
       <div class="form-group"><label class="col-sm-2 control-label">状态</label>
           <div class="col-sm-10">
               <!--#if($!{user})修 改#else提 交#end-->
               <!--<input type="text" class="form-control" name="state" value="$!{item.itemState}"  >-->
               <select name="itemState" id="itemState" class="form-control" >
                   <option value="1"  #if($!{item.itemState}==1) selected="selected" #end >上架</option>
                   <option value="-1"  #if($!{item.itemState}==-1) selected="selected" #end >下架</option>
               </select>
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">一级分类</label>
           <div class="col-sm-10">
               <input type="text" class="form-control" name="itemCategoryPrimary" value="$!{item.itemCategoryPrimary}"  >
           </div>
       </div>

       <div class="form-group"><label class="col-sm-2 control-label">二级分类</label>
           <div class="col-sm-10">
               <input type="text" class="form-control" name="itemCategorySub" value="$!{item.itemCategorySub}"  >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">品牌</label>
           <div class="col-sm-10">
               <input type="text" class="form-control" name="brandId" value="$!{item.brandId}"  >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">制造日期</label>
           <div class="col-sm-10">
               <input type="text" id="createDate" class="form-control" name="createDate" value="$!{item.createDate}"  >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">排序因子</label>
           <div class="col-sm-10">
               <input type="text" class="form-control" name="sortFactor"  value="$!{item.sortFactor}" >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">点评佣金比率</label>
           <div class="col-sm-10">
               <input type="text" class="form-control" name="evaluateBonusRate"  value="$!{item.evaluateBonusRate}" >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">点评佣金数量</label>
           <div class="col-sm-10">
               <input type="text" class="form-control" name="evaluateBonusValue"  value="$!{item.evaluateBonusValue}" >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">分享佣金比率</label>
           <div class="col-sm-10">
               <input type="text" class="form-control" name="sharedBonusRate" value="$!{item.sharedBonusRate}"  >
           </div>
       </div>
       <div class="form-group"><label class="col-sm-2 control-label">分享佣金数量</label>
           <div class="col-sm-10">
               <input type="text" class="form-control" name="sharedBonusValue" value="$!{item.sharedBonusValue}"  >
           </div>
       </div>
        <div class="form-group">
            <div class="text-center">
                <button class="btn btn-primary" type="submit">修 改</button>
            </div>
        </div>
    </form>
</div>
<script src="#springUrl('/static/js/jquery-2.1.1.js')"></script>
<script src="#springUrl('/static/plugins/nice-validator-0.8.1/jquery.validator.js?local=zh-CN')"></script>
<script src="#springUrl('/static/js/jquery-ui.custom.min.js')"></script>
<script src="#springUrl('/static/js/jquery-ui-1.10.4.min.js')"></script>
<script type="text/javascript">
    $(function(){
        $( "#createDate" ).datepicker({
            altField: "#alternate",
            altFormat: "DD, d MM, yy"
        });
    });
$("#myForm").validator({
    valid: function(form){
        var me = this;
        // 提交表单之前，hold住表单，防止重复提交
        me.holdSubmit();
        $.ajax({
        	url: "#springUrl('/item/editItem')",
            data: $(form).serialize(),
            type: "POST",
            success: function(data){
            	var d = JSON.parse(data);
                if(d.success && d.data){
                	window.parent.location.reload();
                	//当你在iframe页面关闭自身时
                	//var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                	//parent.layer.close(index); //再执行关闭   
                } else {
                	//失败，提交表单成功后，释放hold，如果不释放hold，就变成了只能提交一次的表单
                    me.holdSubmit(false);
                }
            }
        });
    }
});
</script>
</body>
</html>
